﻿using System;
using System.Collections.Generic;

namespace Components.Data.UI.Controls
{
  public class ControlBindingCollection : List<ControlBinding>
  {
    public ControlBinding this[String controlID]
    {
      get
      {
        return this.Find(cb => cb.Control.ID == controlID.ToLowerInvariant());
      }
      set
      {
        ControlBinding controlBinding = this.Find(cb => cb.Control.ID == controlID.ToLowerInvariant());

        if (controlBinding != null)
        {
          controlBinding = value;
          return;
        }
        this.Add(value);
      }
    }
  }
}